﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Configuration;
using System.Collections.Specialized;

namespace KingSite.Library.Compress {
    public class ZipHelper {
        static IZipSetting zipSetting = new ZipSetting();

        public static IZip GetInstance() {
            string[] type = zipSetting.ZipType.Split(',');
            string a = type[1];
            string n = type[0];
            Assembly ass = Assembly.Load(a);
            Type[] t = ass.GetTypes();
            object o = ass.CreateInstance(n);
            return (IZip)o;
        }
    }

    public interface IZipSetting {
        string ZipType { get; }
    }

    public class ZipSetting : IZipSetting {
        public string ZipType {
            get { return ((NameValueCollection)ConfigurationManager.GetSection("KingSiteLibrary/Compress"))["ZipType"]; }
        }
    }
}
